Not Applicable
1. Field of Invention
The present invention relates generally to a compiler that uses stack-based memory.
2. Description of Prior Art
Currently compilers used in computer programs for high-level language compilation use a stack structure for storing registers, parameters, and local variables. The data is always kept in fixed size memory for local variables. There exist computer systems, which have multi-stack memory architectures where local variables and registers are placed in two different stacks, as in U.S. Pat. No. 6,138,210 (2000). These fixed size local variable and register areas however, do not allow for the creation of run-time variables in the stack. Existing compilers create run-time variables in separate memory locations that are referred to as the heap, as is found in the C++ language compiler.
If the size of the local variable area is known at the moment when a subprogram is to be called, the area can be created in the stack as described by Fischer and LeBlanc in xe2x80x9cCrafting a Compiler with Cxe2x80x9d, Benjamin/Cummings Publishing Co. Inc., 1991, pp. 289-292, Redwood City, Calif., ISBN 0-8053-2166-7. However at execution time a function cannot create any additional area in the stack and the necessity of the heap remains.
Having two different locations for local variables allocated during compilation and at run-time creates additional complexities in high-level languages. This is especially true for object-oriented programming languages where large numbers of run-time variables are created. As run time variables are deleted fragmentation of the heap can occur.
Accordingly, the present invention provides a mechanism to change the stack area that is given for local variables so that both compile time and run time local variables can be created in the stack. This was considered an insoluble problem. It also becomes possible to delete compile time created variables at run time. This problem had not been recognized in the prior art.
As a consequence the use of the heap is no longer necessary and fragmentation no longer occurs.